package cn.xmy.demo01.servlet;

import cn.xmy.demo01.service.ShopInfoService;
import cn.xmy.demo01.service.impl.ShopInfoServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;


import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

@WebServlet("/deleteShopInfoServlet")
public class DeleteShopInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ShopInfoService shopInfoService=new ShopInfoServiceImpl();
        String id=request.getParameter("id");
        try {
            int rows=shopInfoService.deleteShopInfo(id);
            PrintWriter out=response.getWriter();
            out.print(rows);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}